package com.mocha.nezha.dmo.entity;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mocha.nezha.dmo.PointBO;
import com.mocha.nezha.nezha.PoleEdge;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 摄像头
 * @author songkui
 * @since 2024/2/21 17:24
 */
@Data
@EqualsAndHashCode(of ={"id"}, callSuper = false)
@Accessors(chain = true)
@TableName("vt_config.pole_point")
public class PolePointPGEntity {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    //从杆子pole_code
    @TableField("source")
    private String source;

    //到杆子pole_code
    @TableField("target")
    private String target;

    //距离【米】
    @TableField("distance")
    private Integer distance;

    //定位 list JSON
    @TableField("point_json")
    private String pointJson;

    //所属园区
    @TableField("park_code")
    private String parkCode;


    //点位编号【多个逗号隔开】
    @TableField("points")
    private String points;


    public PoleEdge buildEdge(){
        PoleEdge edge = new PoleEdge();
        edge.setSourcePoleCode(source);
        edge.setTargetPoleCode(target);
        edge.setDistance(distance);
        edge.setPointList(JSONArray.parseArray(this.getPointJson(), PointBO.class));
        return edge;
    }


}
